<admintpl file="header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:U('Admin/Area/index')}">地区列表</a></li>
    </ul>
    <form class="well form-search" id="query_form" method="post" action="{:U('Admin/News/index')}">
        地区名称：
        <input type="text" name="areaName" style="width: 120px;" value="{$formParam.areaName}" placeholder="地区名称...">
        <input type="button" name="query_form_btn" id="queryBtn" data-action="{:U('Admin/Area/index')}"  class="btn btn-primary" value="查询"/>
        <a href='{:U("Admin/Area/areaAdd")}' class="btn btn-primary" >开通地区</a>
        <br/><br/>
        
    </form>
    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>索引</th>
                <th>城市名称</th>
                <th width="900">管理员</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php $tmp_key = 0;?>
            <foreach name="data" item="vo">
                <tr>
                	<?php
                		if($old_initial !=$vo['initial']){
                	?>
                    <td rowspan="<?php echo $count_data[$tmp_key]?>">{$vo['initial']}</td>
                    <?php
                    		$old_initial = $vo['initial'];
                    		$tmp_key++;
                    	}
                    ?>
                    <td>{$vo['name']}</td>
                    <td style="word-wrap:break-word;word-break:break-all;">{$vo['administrator_str']}<a style="float:right;"  class="btn btn-primary"  onclick="edit_admin({$vo["area_id"]})">修改</a></td>
                    <td>
                        <if condition="$vo.disable_status ==1 ">
                                <a href='{:U("Admin/Area/open",array("id"=>$vo["area_id"])) }'
                                   class="js-ajax-dialog-btn text-success">启用</a>
                                <else/>
                                <a href='{:U("Admin/Area/close",array("id"=>$vo["area_id"])) }'
                                   class="js-ajax-dialog-btn text-error">禁用</a>
                        </if>
                        <a href='{:U("Admin/Area/del",array("areaId"=>$vo["area_id"]))}' class="js-ajax-dialog-btn"
                           data-msg="确定要删除此地区吗？">删除</a>
                        <a href="{:U('News/index',array('area_id'=>$vo['area_id']))}" >进入新闻列表</a>
                        <a onclick="edit_liverole('{$vo.area_id}','{$vo.live_status}')" style="margin-left: 25px;">直播权限设置</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
    </form>
    <div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
    $(document).ready(function () {
        $('input[name="query_form_btn"]').click(function () {
            $('#query_form').attr('action', $(this).attr('data-action'));
            $('#query_form').submit();
        });
    });
    
 function edit_admin(area_id){
	  layer.open({
  	    type: 2,
  	    //skin: 'layui-layer-lan',
  	    title: '修改地区管理员',
  	    fix: false,
  	    shadeClose: true,
  	    maxmin: true,
  	    area: ['1000px', '500px'],
  	    content: "<?php echo U('Admin/Area/editAdmin')?>"+'&area_id='+area_id,
  	    end: function(){
  	    	location.reload();
  	    }
  	  });
 }
    function edit_liverole(area_id,live_status){
        layer.open({
            type: 2,
            //skin: 'layui-layer-lan',
            title: '修改地区管理员',
            fix: false,
            shadeClose: true,
            maxmin: true,
            area: ['1000px', '500px'],
            content: "<?php echo U('Admin/Area/editliverole')?>"+'&area_id='+area_id+'&live_status='+live_status,
            end: function(){
                location.reload();
            }
        });
    }
</script>
</body>
</html>